package com.tutu.mybatis.dynamic.datasource.util;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;
import java.util.Objects;

/**
 * @author qyy
 * @date 2021/4/1 8:48
 */
public class Long2StringJsonSerializer extends JsonSerializer<Long> {

    @Override
    public void serialize(Long value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        gen.writeString(Objects.nonNull(value) ? value.toString() : "");
    }
}
